function Hnew=H2newH(H,vecind,vecscale); 
% Get a Hessian H and scale it in particular directions for good
% performance 
% H         original Hessian 
% VECIND    Indicator of coefficients wish to rescale the STD 
% VECSCALE  Indicator of constants to rescale std; 
n=length(vecind); 
if length(vecscale)~=n; error('VECIND and VESCALE are not the same size'); end; 
Hnew=H; 
ii=1; 
for ii=1:n 
    rc=vecind(ii); 
    Hnew(rc,:)=vecscale(ii)*H(rc,:); 
    Hnew(:,rc)=vecscale(ii)*H(:,rc); 
    %Hnew(rc,rc)=Hnew(rc,rc)*vecscale(ii); 
end 
[Hc,p]=chol(Hnew); 
if p~=0; 
    error('Hnew is not positive definite') 
end 
